<?php
include  'Util.php';
$link = Util::getLink();

$query = sprintf(Util::$select_jornakUsers,
    mysql_real_escape_string($_POST["element_1"]),
    mysql_real_escape_string(Util::hash($_POST["element_1"], $_POST["element_2"]))
);

$result = mysql_query($query);

if (!$result) {
    $message  = 'Invalid query: ' . mysql_error() . "\n";
    $message .= 'Whole query: ' . $query;
    die($message);
}

while ($row = mysql_fetch_assoc($result)) {
    session_start();
    session_regenerate_id();
    $_SESSION['SESS_MEMBER_ID']=$row['id'];
    //Write session to disc
    session_write_close();
    header("location: form/news.php");
}

Util::closeLink($link);
exit();
?>
